<!DOCTYPE html>
<html>
	<head lang="en">
		<title>我的所有评论</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="/js/bootstrap/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/strategyComment.css" />
		<script src="/js/plugins/jrender/jrender.js"></script>
		<link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
		<script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
		<script src="/js/common.js"></script>
		<script>

            $(function () {
                var id = getParams().id;
                var users = sessionStorage.getItem('user');
                user = JSON.parse(users);
                $(function () {

                    //评中评
                        //判断用户是否登录,如果登录则可以点评,反之跳转回首页登录
                        if(sessionStorage.getItem('user') == null){
                            $(".submitBtn").confirm({
                                title: '温馨提示',
                                content: '亲,您需要登录才能评价哦',
                                buttons: {
                                    跳转回首页: function () {
                                        window.location.href="/index.html";
                                    },
                                    取消: function () {
                                    },
                                }
                            })
                        }else{
                            $(".submitBtn").click(function () {
                                var msg = $("#msg").val();
                                if (msg) {
                                    $.post("/strategies/replaycomment/" + id, {
                                        content: msg,
                                        "userId": user.id,
                                        "comment.id": id
                                    }, function (data) {
                                        if (data.success) {
                                            location.reload();
                                        }
                                    })
                                } else {
                                }
                            })
                        }
                    });

                // 通过session获取用户id
                var id = getParams().id;
                var users = sessionStorage.getItem('user');
                user = JSON.parse(users);


				//获取当前用户下面的点评
                $.get("/strategies/" + id +"/commentreplay",function (data) {
                    console.log(data);
                    //回显点评
                    $("#comments").renderValues(data,{
                    });
                })

                //获取当前用户下面的点评总数
                var num = $.get("/strategies/" + id +"/countId",function (data) {
                    console.log(data);
                    $(".p-21 span").html(data);
                })

                //获取点评详细内容
                $.get("/strategies/comment/"+id,function (data) {
                    console.log(data);
                    //回显点评
                    $("#comment").renderValues(data,{
                        starHandler:function (ele,value) {
                            var num = 0;
                            while (num<value){
                                $(ele).append('<i class="fa fa-star"></i>');
                                num++;
                            }
                            while(num<5){
                                $(ele).append('<i class="fa fa-star-o"></i>');
                                num++;
                            }
                        },
                        userHandler:function (ele,value) {
                            ele.href="/userProfiles.html?id="+value;
                        },
                        commentHandler:function (ele,value) {
                            ele.href="strategyCatalogs.html?strategyId="+value;
                        }
                    });
                })
            })
		</script>
	</head>
	<body>

		<div class="search-head">
			<div class="row nav-search">
				<div class="col">
					<a href="javascript:history.go(-1);">
						<span><i class="fa fa-chevron-left"></i></span>
					</a>
				</div>
				<div class="col">
					<span>我的所有评论</span>
				</div>
				<div class="col"></div>
			</div>
		</div>

		<div id="comment">
			<div class="bs-example bs-example-type" data-example-id="simple-headings">
				<table class="table">
					<tbody>
					<tr>
						<td><h1>h1. Bootstrap heading</h1></td>
						<td class="type-info">Semibold 36px</td>
					</tr>
					<tr>
						<td><h2>h2. Bootstrap heading</h2></td>
						<td class="type-info">Semibold 30px</td>
					</tr>
					<tr>
						<td><h3>h3. Bootstrap heading</h3></td>
						<td class="type-info">Semibold 24px</td>
					</tr>
					<tr>
						<td><h4>h4. Bootstrap heading</h4></td>
						<td class="type-info">Semibold 18px</td>
					</tr>
					<tr>
						<td><h5>h5. Bootstrap heading</h5></td>
						<td class="type-info">Semibold 14px</td>
					</tr>
					<tr>
						<td><h6>h6. Bootstrap heading</h6></td>
						<td class="type-info">Semibold 12px</td>
					</tr>
					</tbody>
				</table>
			</div>

            <br>
			<div id="comments">
				<div render-loop="list">
					<div class="container row comment">
						<div class="col-2 comment-head">
							<a href="userProfiles.html" render-key="list.user.id" render-fun="userHandler">
								<img class="rounded-circle"
									 render-src="list.user.headImgUrl">
							</a>
						</div>
						<div class="col comment-right">
							<p class="authorName"><span render-html="list.user.nickName"></span>
							<span class="comment-date" render-html="list.releaseTime"></span>
								<div class="comment-content">
									<a  render-key="list.id" render-fun="commentHandler">
										<p render-html="list.content">
										</p>
									</a>
								</div>
							</p>
						</div>
					</div>
				</div>
			</div>
</body>

</html>